package org.spring.blog.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Data
@AllArgsConstructor
@Accessors(chain = true)
@Entity
@Table(name = "tb_user")
public class User implements Serializable {

    private static final long serialVersionUID = -6060319662398725369L;

    @Id
    @Column(name = "id")
    private String id;

    @Column(name = "user_name")
    private String userName;

    @Column(name = "password")
    private String password;

    @Column(name = "roles")
    private String roles;

    @Column(name = "avatar")
    private String avatar;

    @Column(name = "email")
    private String email;

    @Column(name = "sign")
    private String sign;

    @Column(name = "state")
    private String state;

    @Column(name = "reg_ip")
    private String regIp;

    @Column(name = "login_ip")
    private String loginIp;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "update_time")
    private Date updateTime;

    public User() {
    }

    public User(String _id, String _userName, String _roles, String _avatar, String _email, String _sign, String _state, String _regIp, String _loginIp, Date _createTime, Date _updateTime) {
        id = _id;
        userName = _userName;
        roles = _roles;
        avatar = _avatar;
        email = _email;
        sign = _sign;
        state = _state;
        regIp = _regIp;
        loginIp = _loginIp;
        createTime = _createTime;
        updateTime = _updateTime;

        // complete data
        password = "";
    }

    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
        throw new java.io.NotSerializableException("org.spring.blog.pojo.User");
    }

    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
        throw new java.io.NotSerializableException("org.spring.blog.pojo.User");
    }
}
